package com.ruoyi.web.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.PubBlog;
import com.ruoyi.system.domain.PubNavigation;
import com.ruoyi.system.domain.PubNavigationType;
import com.ruoyi.system.service.IPubBlogService;
import com.ruoyi.system.service.IPubNavigationService;
import com.ruoyi.system.service.IPubNavigationTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
/**
 * 导航Controller
 *
 * @author 贡小天
 * @date 2024年4月12日
 */
@RestController
@RequestMapping("/web/navigation")
public class WebNavigationController extends BaseController {

    @Autowired
    private IPubNavigationTypeService pubNavigationTypeService;

    @Autowired
    private IPubNavigationService pubNavigationService;

    /**
     * 获取导航分类 列表
     */
    @GetMapping("/typeList")
    public TableDataInfo list(PubNavigationType pubNavigationType) {
        pubNavigationType.setIsEnable("0");
        startPage();
        List<PubNavigationType> typelist = pubNavigationTypeService.selectPubNavigationTypeList(pubNavigationType);
        for (int i = 0; i < typelist.size(); i++) {
            PubNavigation pubNavigation = new PubNavigation();
            pubNavigation.setType(typelist.get(i).getId());
            typelist.get(i).setPubNavigationList(pubNavigationService.selectPubNavigationList(pubNavigation));
        }
        return getDataTable(typelist);
    }
}
